/*******************************************************************************
 * Copyright (c) Jerges A. Bello G. 2014. Reservado todos los derechos.
 ******************************************************************************/
package com.jabex.common.to;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by jaugusto on 26/08/14. *
 */
public class MessageWithParamsTO implements Serializable {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private String message;
	private Object[] params;

	/**
	 * Lista de mensajes
	 */
	private List<MessageWithParamsTO> msgList;


	public MessageWithParamsTO(String message, Object... params) {
		this.message = message;
		this.params = params;
	}

	public MessageWithParamsTO(String message) {
		this.message = message;
	}

	public String getMessage() {
		return message;
	}

	public Object[] getParams() {
		return params;
	}

	public List<MessageWithParamsTO> getMsgList() {
		return msgList;
	}

	public void setMsgList(List<MessageWithParamsTO> msgList) {
		this.msgList = msgList;
	}

	public void addMessage(MessageWithParamsTO msg) {
		if (msgList == null)
			msgList = new ArrayList<MessageWithParamsTO>(1);
		msgList.add(msg);
	}

	public void addMessages(List<MessageWithParamsTO> msgs) {
		if (msgList == null)
			msgList = new ArrayList<MessageWithParamsTO>(msgs != null ? msgs.size() : 0);
		if (msgs != null && !msgs.isEmpty())
			msgList.addAll(msgs);
	}

	public void addNewMessage(String code, Object... params) {
		addMessage(new MessageWithParamsTO(code, params));
	}

	public void setParams(Object[] params) {
		this.params = params;
	}
}
